package com.xiaomi.by_spring;

public class Order {
    private Coffee coffee;
    //1. 通过构造器注入Coffee对象
    public Order(Coffee coffee) {
        this.coffee = coffee;
    }
    //2. 通过setter方法注入Coffee对象
//    public void setCoffee(Coffee coffee) {
//        this.coffee = coffee;
//    }
    public void placeOrder() {
        System.out.println("订单买了" + coffee.getName());
    }
}
